package com.ldy.frame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import static com.ldy.frame.PFrame.TextVideo;


/**
 * Created by MacBook Pro on 2017/11/28.
 */
public class ButtonPanel extends JPanel{
    JPanel west,center,east;
    JButton b1,b2,b3,b4,b5,b6;
    public ButtonPanel()
    {
        //创建布局
        this.setLayout(new GridLayout(1,3));
        west =new JPanel();
        center =new JPanel();
        center.setLayout(new GridLayout(9,1));
        east =new JPanel();
        //center.setLayout(new GridLayout(3,1));
        //创建按钮
         b1 =new JButton("按钮1");
         b2 =new JButton("按钮2");
         b3 =new JButton("按钮3");
         b4 =new JButton("按钮4");
         b5 =new JButton("按钮5");
         b6 =new JButton("按钮6");

        //按钮1添加监听器
         b1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                TextVideo.ta.setText("");
                TextVideo.ta.append("hello world!\n");
                TextVideo.ta.append("这是视频流显示板块\n");
                TextVideo.ta.append("---------------------------------\n");


            }
        });
        b2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        b3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        b4.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        b5.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        b6.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });

        //布局添加按钮

        center.add(b1);
        center.add(b2);

        center.add(b3);
        center.add(b4);

        center.add(b5);
        center.add(b6);



        //按钮模块添加布局
        this.add(new JPanel());
        this.add("Center",center);
        //east.setLayout(new GridLayout(2,2));
        this.add(new JPanel());


    }

    public static void main(String[] args) {
        JFrame j =new JFrame("测试");
        j.getContentPane().add(new ButtonPanel());
        j.setSize(500,500);
        j.setVisible(true);
        j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}
